package gui;

import javax.swing.JFrame;
import javax.swing.WindowConstants;
import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.skin.TwilightSkin;
import java.awt.BorderLayout;
import java.awt.Toolkit;
import java.io.IOException;
import kontroler.Kontroler;

public class Aplication {

	private JImagePanel iPanel = null;
	private JFrame jFrame = null;  //  @jve:decl-index=0:visual-constraint="52,25"
	private Menu menu = null;
	private CenterPanel centerPanel = null;
	private WestPanel westPanel = null;
	private Kontroler kontroler = null;  //  @jve:decl-index=0:
	private SouthPanel southPanel = null;

	//@throws IOException 
	public void initialization() throws IOException {
		kontroler = new Kontroler();
		JFrame.setDefaultLookAndFeelDecorated(true);
		getJFrame();
		setLookAndFeel();
		jFrame.setVisible(true);
		//iPanel.setImage("D:/DG/1_6551_0.jpg");
	}
	
	private JFrame getJFrame() {
		if (jFrame == null) {
			jFrame = new JFrame();
			jFrame.setSize(Toolkit.getDefaultToolkit().getScreenSize());
			jFrame.setLocation(0, 0);
			jFrame.setTitle("stat");
			jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
			jFrame.setLayout(new BorderLayout());
			jFrame.add(getPanel());
			jFrame.add(getMenu(),BorderLayout.NORTH);
			jFrame.add(getWestPanel(), BorderLayout.WEST);
			jFrame.add(getCenterPanel(),BorderLayout.CENTER);
			jFrame.add(getSouthPanel(), BorderLayout.SOUTH);
			
		}
		return jFrame;
	}
	
	private Menu getMenu(){
		if (menu == null) {
			menu = new Menu();
		}
		return menu;
	}
	private JImagePanel getPanel(){
		if (iPanel == null) {
			iPanel = new JImagePanel();
		}
		return iPanel;
	}
	private CenterPanel getCenterPanel() {
		if (centerPanel == null) {
			centerPanel = new CenterPanel(westPanel);
		}
		return centerPanel;
	}
	private WestPanel getWestPanel() {
		if (westPanel == null) {
			westPanel = new WestPanel(kontroler);
		}
		return westPanel;
	}
	private SouthPanel getSouthPanel(){
		if (southPanel == null){
			southPanel = new SouthPanel(centerPanel);
		}
		return southPanel;
	}
	private void setLookAndFeel(){
		SubstanceLookAndFeel.setSkin(new TwilightSkin());
	}
}